package com.xmj.web.controller.billing;

import com.xmj.billing.domain.BarberShopBillings;
import com.xmj.billing.service.IBarberShopBillingsService;
import com.xmj.common.annotation.Log;
import com.xmj.common.core.controller.BaseController;
import com.xmj.common.core.domain.AjaxResult;
import com.xmj.common.core.page.TableDataInfo;
import com.xmj.common.enums.BusinessType;
import com.xmj.common.utils.poi.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 收银Controller
 *
 * @author ohh
 * @date 2024-04-21
 */
@RestController
@RequestMapping("/billing/BarberShopBillings")
public class BarberShopBillingsController extends BaseController
{
    @Autowired
    private IBarberShopBillingsService barberShopBillingsService;

    /**
     * 查询收银列表
     */
    @PreAuthorize("@ss.hasPermi('billing:BarberShopBillings:list')")
    @GetMapping("/list")
    public TableDataInfo list(BarberShopBillings barberShopBillings)
    {
        startPage();
        List<BarberShopBillings> list = barberShopBillingsService.selectBarberShopBillingsList(barberShopBillings);
        return getDataTable(list);
    }

    /**
     * 导出收银列表
     */
    @PreAuthorize("@ss.hasPermi('billing:BarberShopBillings:export')")
    @Log(title = "收银", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BarberShopBillings barberShopBillings)
    {
        List<BarberShopBillings> list = barberShopBillingsService.selectBarberShopBillingsList(barberShopBillings);
        ExcelUtil<BarberShopBillings> util = new ExcelUtil<BarberShopBillings>(BarberShopBillings.class);
        util.exportExcel(response, list, "收银数据");
    }

    /**
     * 获取收银详细信息
     */
    @PreAuthorize("@ss.hasPermi('billing:BarberShopBillings:query')")
    @GetMapping(value = "/{billingID}")
    public AjaxResult getInfo(@PathVariable("billingID") Long billingID)
    {
        return success(barberShopBillingsService.selectBarberShopBillingsByBillingID(billingID));
    }

    /**
     * 新增收银
     */
    @PreAuthorize("@ss.hasPermi('billing:BarberShopBillings:add')")
    @Log(title = "收银", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BarberShopBillings barberShopBillings)
    {
        return toAjax(barberShopBillingsService.insertBarberShopBillings(barberShopBillings));
    }

    /**
     * 修改收银
     */
    @PreAuthorize("@ss.hasPermi('billing:BarberShopBillings:edit')")
    @Log(title = "收银", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BarberShopBillings barberShopBillings)
    {
        return toAjax(barberShopBillingsService.updateBarberShopBillings(barberShopBillings));
    }

    /**
     * 删除收银
     */
    @PreAuthorize("@ss.hasPermi('billing:BarberShopBillings:remove')")
    @Log(title = "收银", businessType = BusinessType.DELETE)
	@DeleteMapping("/{billingIDs}")
    public AjaxResult remove(@PathVariable Long[] billingIDs)
    {
        return toAjax(barberShopBillingsService.deleteBarberShopBillingsByBillingIDs(billingIDs));
    }
}
